#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 5e4 + 5;

int n, m;
int a[N], f[N], g[N];
int b[N], pre[N], nxt[N];
void init() {
  map<int, int> pos;
  rep(i, 1, n) b[i] = a[i], pos[b[i]] = i;
  rep(i, 1, n) pre[i] = i - 1, nxt[i] = i + 1;
  nxt[0] = 1, pre[n + 1] = n, nxt[n + 1] = n + 1;
  sort(b + 1, b + n + 1);
  rep(i, 1, n) {
    int id = pos[b[i]];
    int x = pre[id], y = nxt[id];
    pre[y] = x, nxt[x] = y;  // delete b[i] from list
    f[id] = pre[x], g[id] = nxt[y];
  }
}
struct Node {
  int cnt;
  int ch[2];
} tr[N * 90];
#define cnt(p) tr[p].cnt
#define lc(p) tr[p].ch[0]
#define rc(p) tr[p].ch[1]
int rt[N];
int newnode(int p) {
  static int tot = 0;
  ++tot;
  cnt(tot) = cnt(p);
  lc(tot) = lc(p);
  rc(tot) = rc(p);
  return tot;
}
void insert(int& rt, int x) {
  rt = newnode(rt);
  int p = rt;
  cnt(p)++;
  per(i, 29, 0) {
    int c = (x & (1 << i)) ? 1 : 0;
    if (c)
      rc(p) = newnode(rc(p)), p = rc(p);
    else
      lc(p) = newnode(lc(p)), p = lc(p);
    cnt(p)++;
  }
}
int query(int p1, int p2, int x) {
  int res = 0;
  per(i, 29, 0) {
    int c = (x & (1 << i)) ? 1 : 0;
    if (cnt(tr[p2].ch[c]) <= cnt(tr[p1].ch[c])) c ^= 1;
    if (c) res |= (1 << i);
    p1 = tr[p1].ch[c], p2 = tr[p2].ch[c];
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> a[i];
  init();
  rep(i, 1, n) {
    rt[i] = rt[i - 1];
    insert(rt[i], a[i]);
  }
  int ans = 0;
  int mx = *max_element(a + 1, a + n + 1);
  rep(i, 1, n) {
    int L = f[i], R = g[i];
    if (a[i] == mx) continue;
    int x = query(rt[L], rt[R - 1], ~a[i]);
    ans = max(ans, a[i] ^ x);
  }
  cout << ans;
  return 0;
}